package com.daylightrobbery.server.packet.room;


import com.daylightrobbery.server.GameManager;
import com.daylightrobbery.server.entity.Room;
import com.daylightrobbery.server.packet.type.DataPacket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class CreateRoomPacket implements DataPacket {

    private static final Logger log = LoggerFactory.getLogger(CreateRoomPacket.class);

    private String uid;
    private int type = 20000;

    @Override
    public DataPacket process() {
        log.info("Start Create Room...");
        log.info("Create Room finished");
        Room room = GameManager.getInstance().createRoom(this.uid);
        return new ShowRoomPacket().setRoom(room);
    }

    @Override
    public int getType() {
        return type;
    }

    public String getUid() {
        return uid;
    }

    public CreateRoomPacket setUid(String uid) {
        this.uid = uid;
        return this;
    }

    @Override
    public String toString() {
        return "CreateRoomPacket{" +
                "uid='" + uid + '\'' +
                '}';
    }
}
